const BehaviorAll = require("../../../behaviors/behavior_all.js");
const ServiceBranchCompany = require("../../../service/service_branchCompany.js");

Component({
  /**
   * behaviors
   */
  behaviors: [BehaviorAll],
  /**
   * 页面的初始数据
   */
  data: {
    staffs: [],
    /**
     * 开始页
     */
    startPage: 0
  },

  methods: {
    /**
 * 生命周期函数--监听页面加载
 */
    onLoad: function (options) {
      const _this = this;
      ServiceBranchCompany.getStaffPage(0, function (data) {
        if(data){
          _this.setData({ staffs: data.records });
        }
      });
    },

    /**
     * 触底事件
     */
    onReachBottom: function () {
      const _this = this;
      let startPage = this.data.startPage + 1;
      ServiceBranchCompany.getStaffPage(startPage, function (data) {
        _this.data.staffs.push(...data.records);
        _this.setData({
          staffs: _this.data.staffs,
          startPage: startPage
        });
      });
    }
  }

})